<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class UserSignUp extends Model
{
    protected $table = 'user_sign_up';
    public $timestamps = false;
    use HasFactory;

    public static $statuses = [
        1 => '待支付',
        2 => '已取消',
        3 => '已支付',
        9 => '已退款',
    ];

    public function course()
    {
        return $this->belongsTo(Course::class, 'course_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function evaluate()
    {
        return $this->hasOne(CourseEvaluate::class, 'sign_up_id', 'id');
    }

    public function getOne($userid, $course_id)
    {
        return self::where('user_id', $userid)->where('course_id', $course_id)->first();
    }

}
